<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    var arr = ["abc", "123", "你好", "!", "哈"];

    var str = "abcabc123123哈哈你好!！abc那个123你好好";

    // 真实需要的正则格式：/((abc)|(123)|(你好)|(!)|(哈))+/g

    // 根据敏感词库，拼接创建正则时所需的字符
    var regStr = "";
    for(var i=0;i<arr.length;i++){
        regStr += "("+ arr[i] +")|";
    }
    // 处理创建正则时所需的字符
    regStr = "(" + regStr.slice(0,-1) + ")+";
    
    // 根据拼接好的字符创建正则
    var reg = new RegExp(regStr, "g");

    // 替换
    console.log(str.replace(reg, "*"));
    
</script>
</html>